<template>
    <div class="pack">
        <div class="tree_container">
            <h3>机构列表</h3>
            <div class="treePack">
                <Tree :data="organizationTreeData" @on-select-change="organizationTreeChange"></Tree>
            </div>
        </div>
        <div class="detail_container">
            <h3>气防站值班管理</h3>
            <div class="hunttool" v-if="addduty">
                <Date-picker style="width:150px;float: left;margin-right: 6px;" size="small" type="datetime" placeholder="选择开始日期" v-model="searchBeginTime" @on-change="searchBeginTimeDate"></Date-picker>
                <Date-picker style="width:150px;float: left;margin-right: 6px;" size="small" type="datetime" placeholder="选择结束日期" v-model="searchEndTime" @on-change="searchEndTimeDate"></Date-picker>
                <Button type="primary" icon="ios-search" size="small" @click="searchData">查询</Button>
                <Button type="ghost" icon="ios-trash-outline" size="small" class="deltebtn" @click="batchDelete">批量删除</Button>
                <Button type="ghost" icon="ios-plus-empty" size="small" class="addbtn" @click="addnew">新增</Button>
            </div>
            <div class="compile" v-if="addduty">
                <Table stripe border :columns="columns" :data="tabledata" @on-selection-change="compileSelect"></Table>
            </div>
            <div class="page_container" v-if="addduty">
                <Page :current="pageNo" :total="totalCount" size="small" simple class="page_btn"
                      @on-change="pageChange"></Page>
                <P class="page_text">共{{totalCount}}条</P>
            </div>
            <!--新增修改-->
            <div class="hunttoolreturn" v-if="!addduty">
                <Button type="ghost" icon="arrow-left-c" size="small" class="addbtn" @click="returnBtn">返回</Button>
            </div>
            <div v-show="!addduty">
                <Form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="100" style="margin-right: 20px">
                    <Card class="right-card" dis-hover>
                        <p slot="title">基本信息</p>
                        <Form-item label="所属单位" prop="departmentName">
                            <p>&nbsp;{{formValidate.departmentName}}</p>
                        </Form-item>
                        <Row>
                            <Col span="6">
                            <Form-item label="开始日期" prop="beginTime">
                                <Date-picker type="datetime" placeholder="选择日期" v-model="formValidate.beginTime"
                                             @on-change="beginTimeDate"></Date-picker>
                            </Form-item>
                            </Col>
                            <Col span="6">
                            <Form-item label="结束日期" prop="endTime">
                                <Date-picker type="datetime" placeholder="选择日期" v-model="formValidate.endTime"
                                             @on-change="endTimeDate"></Date-picker>
                            </Form-item>
                            </Col>
                            <Col span="6">
                            <Form-item label="战备等级" prop="combatReadLevel">
                                <Input v-model="formValidate.combatReadLevel" placeholder=""></Input>
                            </Form-item>
                            </Col>
                        </Row>
                    </Card>

                    <Card class="right-card" dis-hover>
                        <p slot="title">执勤状况</p>
                        <Row>
                            <Col span="6">
                            <Form-item label="执勤队长" prop="captain">
                                <Input v-model="formValidate.captain" placeholder=""></Input>
                            </Form-item>
                            </Col>
                            <Col span="6">
                            <Form-item label="执勤班长" prop="monitor">
                                <Input v-model="formValidate.monitor" placeholder=""></Input>
                            </Form-item>
                            </Col>
                            <Col span="6">
                            <Form-item label="电话员" prop="telephoneOpeartor">
                                <Input v-model="formValidate.telephoneOpeartor" placeholder=""></Input>
                            </Form-item>
                            </Col>
                        </Row>
                        <Row>
                            <Col span="6">
                            <Form-item label="值班人数" prop="perNum">
                                <Input-number :min="0" v-model="formValidate.perNum"></Input-number>人
                            </Form-item>
                            </Col>
                            <Col span="6">
                            <Form-item label="应出勤" prop="beAttend">
                                <Input-number :min="0" v-model="formValidate.beAttend"></Input-number>人
                            </Form-item>
                            </Col>
                            <Col span="6">
                            <Form-item label="实出勤" prop="attend">
                                <Input-number :min="0" v-model="formValidate.attend"></Input-number>人
                            </Form-item>
                            </Col>
                        </Row>
                        <Row>
                            <Col span="6">
                            <Form-item label="执勤车辆" prop="vehicleNum">
                                <Input-number :min="0" v-model="formValidate.vehicleNum"></Input-number>台
                            </Form-item>
                            </Col>
                            <Col span="6">
                            <Form-item label="车辆状态" prop="vehicleStatus">
                                <Input v-model="formValidate.vehicleStatus" placeholder=""></Input>
                            </Form-item>
                            </Col>
                        </Row>
                        <Row>
                            <Col span="8">
                            <Form-item label="气防救援车(救援器材)" prop="rescueEquipment" :label-width="165">
                                <Radio-group v-model="formValidate.rescueEquipment">
                                    <Radio label="1">完好</Radio>
                                    <Radio label="0">存在问题（在备注中注明）</Radio>
                                </Radio-group>
                            </Form-item>
                            </Col>
                            <Col span="8">
                            <Form-item label="移动充气车(充气设备)" prop="mobileCharging" :label-width="165">
                                <Radio-group v-model="formValidate.mobileCharging">
                                    <Radio label="1">完好</Radio>
                                    <Radio label="0">停用（在备注中注明）</Radio>
                                </Radio-group>
                            </Form-item>
                            </Col>
                            <Col span="8">
                            <Form-item label="固定式充气设备：" prop="fixedInflation" :label-width="165">
                                <Radio-group v-model="formValidate.fixedInflation">
                                    <Radio label="1">完好</Radio>
                                    <Radio label="0">停用（在备注中注明）</Radio>
                                </Radio-group>
                            </Form-item>
                            </Col>
                        </Row>
                        <Form-item label="其它车辆" prop="otherVehicle" style="padding-right: 110px">
                            <Input v-model="formValidate.otherVehicle" type="textarea"
                                   :autosize="{minRows: 4,maxRows: 8}" placeholder=""></Input>
                        </Form-item>
                    </Card>
                    <Card class="right-card" dis-hover>
                        <p slot="title">其他</p>
                        <Form-item label="工作记事" prop="workMemo" style="padding-right: 110px">
                            <Input v-model="formValidate.workMemo" type="textarea"  :autosize="{minRows: 4,maxRows: 8}"
                                   placeholder=""></Input>
                        </Form-item>
                        <Form-item label="出警记录" prop="alarmRecord" style="padding-right: 110px">
                            <Input v-model="formValidate.alarmRecord" type="textarea" :autosize="{minRows: 4,maxRows: 8}"
                                   placeholder=""></Input>
                        </Form-item>
                        <Form-item label="通知或指令" prop="notice" style="padding-right: 110px">
                            <Input v-model="formValidate.notice" type="textarea"
                                   :autosize="{minRows: 4,maxRows: 8}" placeholder=""></Input>
                        </Form-item>
                        <Form-item label="备注" prop="remarks" style="padding-right: 110px">
                            <Input v-model="formValidate.remarks" type="textarea"
                                   :autosize="{minRows: 4,maxRows: 8}" placeholder=""></Input>
                        </Form-item>
                    </Card>
                    <Row>
                        <Col span="6" offset="18">
                        <Form-item label="值班领导签字" prop="leaderSignature">
                            <Input v-model="formValidate.leaderSignature" placeholder=""></Input>
                        </Form-item>
                        </Col>
                    </Row>
                </Form>
                <div style="text-align: center">
                    <Button type="ghost" @click="returnBtn" style="margin-right: 100px">取消</Button>
                    <Button type="primary" @click="compileSubmit('formValidate')">提交</Button>
                </div>
            </div>
        </div>
        <!--查看值班详情-->
        <Modal v-model="inspectionDuty" title="值班详情" width="900" :closable="false" :mask-closable="false" >
            <Form :model="formValidate" :label-width="100" style="margin-right: 20px">
            <Card class="right-card" dis-hover>
                <p slot="title">基本信息</p>
                <Form-item label="所属单位" prop="">
                    <p>{{formValidate.departmentName}}</p>
                </Form-item>
                <Row>
                    <Col span="7">
                    <Form-item label="开始日期" prop="">
                        <p>{{formValidate.beginTime}}</p>
                    </Form-item>
                    </Col>
                    <Col span="7">
                    <Form-item label="结束日期" prop="">
                        <p>{{formValidate.endTime}}</p>
                    </Form-item>
                    </Col>
                    <Col span="6">
                    <Form-item label="战备等级" prop="">
                        <p>{{formValidate.combatReadLevel}}</p>
                    </Form-item>
                    </Col>
                </Row>
            </Card>
            <Card class="right-card" dis-hover>
                <p slot="title">执勤状况</p>
                <Row>
                    <Col span="6">
                    <Form-item label="执勤队长" prop="">
                        <p>{{formValidate.captain}}</p>
                    </Form-item>
                    </Col>
                    <Col span="6">
                    <Form-item label="执勤班长" prop="">
                        <p>{{formValidate.monitor}}</p>
                    </Form-item>
                    </Col>
                    <Col span="6">
                    <Form-item label="电话员" prop="">
                        <p>{{formValidate.telephoneOpeartor}}</p>
                    </Form-item>
                    </Col>
                </Row>
                <Row>
                    <Col span="6">
                    <Form-item label="值班人数" prop="">
                        <p>{{formValidate.perNum}}人</p>
                    </Form-item>
                    </Col>
                    <Col span="6">
                    <Form-item label="应出勤" prop="">
                        <p>{{formValidate.beAttend}}人</p>
                    </Form-item>
                    </Col>
                    <Col span="6">
                    <Form-item label="实出勤" prop="">
                        <p>{{formValidate.attend}}人</p>
                    </Form-item>
                    </Col>
                    <Col span="6">
                    <Form-item label="执勤车辆" prop="">
                        <p>{{formValidate.vehicleNum}}台</p>
                    </Form-item>
                    </Col>
                    <Col span="6">
                    <Form-item label="车辆状态" prop="">
                        <p>{{formValidate.vehicleStatus}}</p>
                    </Form-item>
                    </Col>
                </Row>
                <Row>
                    <Col span="10">
                    <Form-item label="气防救援车(救援器材)" :label-width="130" prop="">
                        <Radio-group v-model="formValidate.rescueEquipment" >
                            <Radio label="1" disabled>完好</Radio>
                            <Radio label="0" disabled>存在问题</Radio>
                        </Radio-group>
                    </Form-item>
                    </Col>
                    <Col span="10">
                    <Form-item label="移动充气车(充气设备)" :label-width="130" prop="">
                        <Radio-group v-model="formValidate.mobileCharging" >
                            <Radio label="1" disabled>完好</Radio>
                            <Radio label="0" disabled>停用</Radio>
                        </Radio-group>
                    </Form-item>
                    </Col>
                </Row>
                <Row>
                </Row>
                <Row>
                    <Col span="12">
                    <Form-item label="固定式充气设备" :label-width="130" prop="">
                        <Radio-group v-model="formValidate.fixedInflation" >
                            <Radio label="1" disabled>完好</Radio>
                            <Radio label="0" disabled>停用</Radio>
                        </Radio-group>
                    </Form-item>
                    </Col>
                </Row>
                <Form-item label="其它车辆" prop="" >
                    <Input v-model="formValidate.otherVehicle" type="textarea" readonly  placeholder=""></Input>
                </Form-item>
            </Card>
            <Card class="right-card" dis-hover>
                <p slot="title">其他</p>
                <Form-item label="工作记事" prop="" >
                    <Input v-model="formValidate.workMemo" type="textarea" readonly  placeholder=""></Input>
                </Form-item>
                <Form-item label="出警记录" prop="" >
                    <Input v-model="formValidate.alarmRecord" type="textarea" readonly  placeholder=""></Input>
                </Form-item>
                <Form-item label="通知或指令" prop="" >
                    <Input v-model="formValidate.notice" type="textarea" readonly  placeholder=""></Input>
                </Form-item>
                <Form-item label="备注" prop="" >
                    <Input v-model="formValidate.remarks" type="textarea" readonly  placeholder=""></Input>
                </Form-item>
            </Card>
            </Form>
            <div slot="footer">
                <Button type="primary" @click="recordCancel">关闭</Button>
            </div>
        </Modal>
    </div>
</template>
<script type="text/javascript">
    var ezjsUtil = Vue.ezjsUtil;
    var apiConstants = ezjsUtil.constants.api;
    export default {
        components: {},
        data() {
            const validateBeginTime = (rule, value, callback) => {
                if (value === '') {
                    callback(new Error('请选择日期'));
                } else {
                    callback();
                }
            };
            const validateEndTime = (rule, value, callback) => {
                if (value === '') {
                    callback(new Error('请选择日期'));
                }else if( new Date(this.formValidate.beginTime).getTime() >= new Date(this.formValidate.endTime).getTime()){
                    callback(new Error('结束日期不正确'));
                }else {
                    callback();
                }
            };
            return {
                departmentCode:CURRENT_LEADER.departmentCode,  //登录人员code值
                valueLen:'', //点击树获得值的长度
                //机构树
                organizationTreeData:[],
                //新增值班显示
                addduty: true,
                compiletitle: "添加执勤状况",
                //记录批量删除id
                compiledele: "",
                //当前页
                pageNo: 1,
                //总共多少页
                totalPage: '',
                //表格总共记录数
                totalCount: 0,
                //值班详情弹窗
                inspectionDuty: false,
                //查询物资名称
                valueEsName: '',
                //搜索开始时间
                searchBeginTime:'',
                //搜索结束时间
                searchEndTime:'',
                //下拉列表
                model1: "all",
                cityList: [
                    {
                        value: 'all',
                        label: '全部'
                    },
                ],
                //表格头部信息
                columns: [
                    {
                        type: 'selection',
                        width: 60,
                        align: 'center'
                    },
                    {
                        type: 'index',
                        width: 60,
                        align: 'center'
                    },
                    {
                        title: '所属单位',
                        key: 'departmentName',
                    },
                    {
                        title: '开始日期',
                        key: 'beginTime',
/*                        render: function (h, params) {
                            var newTime = new Date(params.row.beginTime);
                            var Y = newTime.getFullYear();
                            var M = newTime.getMonth() + 1;
                            var D = newTime.getDate();
                            var H = newTime.getHours();
                            var m = newTime.getMinutes();
                            var s = newTime.getSeconds();
                            var time = Y + "-" + M + "-" + D+" "+H+":"+m+":"+s;
                            return h('div', time);
                        }*/
                    },
                    {
                        title: '结束日期',
                        key: 'endTime',
//                        render: function (h, params) {
//                            var newTime = new Date(params.row.endTime);
//                            var Y = newTime.getFullYear();
//                            var M = newTime.getMonth() + 1;
//                            var D = newTime.getDate();
//                            var H = newTime.getHours();
//                            var m = newTime.getMinutes();
//                            var s = newTime.getSeconds();
//                            var time = Y + "-" + M + "-" + D+" "+H+":"+m+":"+s;
//                            return h('div', time);
//                        }
                    },
                    {
                        title: '执勤队长',
                        key: 'captain'
                    },
                    {
                        title: '操作',
                        key: 'action',
                        width: 220,
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('Button', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        marginRight: '5px'
                                    },
                                    on: {
                                        click: () => {
                                            this.examineDuty(params.row);
                                        }
                                    }
                                }, '查看'),
                                h('Button', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        marginRight: '5px'
                                    },
                                    on: {
                                        click: () => {
                                            this.amend(params.row)
                                        }
                                    }
                                }, '修改'),
                                h('Button', {
                                    props: {
                                        type: 'error',
                                        size: 'small'
                                    },
                                    on: {
                                        click: () => {
                                            this.gasDutyRemoveByIds(params.row.id)
                                        }
                                    }
                                }, '删除')
                            ]);
                        }
                    }
                ],
                //表格数据
                tabledata: [],
                //新增表单
                formValidate: {
                    id: '',
                    departmentCode: '',
                    departmentCodeCopy: '',
                    departmentName:'',
                    departmentNameCopy:'',
                    beginTime: '',
                    endTime: '',
                    combatReadLevel: '',
                    captain: '',
                    monitor: '',
                    telephoneOpeartor: '',
                    perNum: 0,
                    beAttend: 0,
                    attend: 0,
                    vehicleNum: 0,
                    vehicleStatus: '',
                    rescueEquipment: '1',
                    mobileCharging: '1',
                    fixedInflation: '1',
                    otherVehicle: '',
                    workMemo: '',
                    alarmRecord: '',
                    notice: '',
                    remarks: '',
                    combatReadLevel: '',
                    leaderSignature:'',
                },
                //表单验证
                ruleValidate: {
                    departmentName:[
                        {required: true, message: '请在左侧选择所属单位', trigger: 'change'}
                    ],
                    beginTime: [
                        {required: true, validator: validateBeginTime, trigger: 'change'}
                    ],
                    endTime: [
                        {required: true, validator: validateEndTime, trigger: 'change'}
                    ],
                    combatReadLevel: [
                        {required: true, whitespace: true, message: '请填写战备等级', trigger: 'blur'}
                    ],
                    captain: [
                        {required: true, whitespace: true, message: '请填写执勤队长', trigger: 'blur'}
                    ],
                    perNum: [
                        {type: 'integer', message: '数值不正确', trigger: 'change'}
                    ],
                    beAttend: [
                        {type: 'integer', message: '数值不正确', trigger: 'change'}
                    ],
                    attend: [
                        {type: 'integer', message: '数值不正确', trigger: 'change'}
                    ],
                    vehicleNum: [
                        {type: 'integer', message: '数值不正确', trigger: 'change'}
                    ],
                },


                //查看值班详细
                columnDuty: [
                    {
                        type: 'index',
                        width: 60,
                        align: 'center'
                    },
                    {
                        title: '执勤车编号',
                        key: 'dutyVehicleNum',
                        align: 'center'
                    },
                    {
                        title: '车组长',
                        key: 'vehicleCaptain',
                        align: 'center'
                    },
                    {
                        title: '驾驶员',
                        key: 'driver',
                        align: 'center'
                    },
                    {
                        title: '1号员',
                        key: 'oneNumber',
                        align: 'center'
                    },
                    {
                        title: '3号员',
                        key: 'threeNumber',
                        align: 'center'
                    },
                    {
                        title: '4号员',
                        key: 'fourNumber',
                        align: 'center'
                    },
                    {
                        title: '5号员',
                        key: 'fiveNumber',
                        align: 'center'
                    },
                ],
                //查看执勤状况弹窗表数据
                dataRecord: [],
                //查看执勤状况表格分页
                RecordPage: {
                    groupDutyId: '',
                    pageNo: 1,
                    totalCount: 0,
                    totalPage: 0,
                }
            }
        },
        computed: {},
        created() {
            this.gasDutyFlipList();
            this.organizationFlipList();
        },
        methods: {
            searchBeginTimeDate(date){
                this.searchBeginTime = date;
            },
            searchEndTimeDate(date){
                this.searchEndTime = date;
            },
            beginTimeDate(date) {
                this.formValidate.beginTime = date;
            },
            endTimeDate(date) {
                this.formValidate.endTime = date;
            },
            //机构树点击事件
            organizationTreeChange(val){
                this.valueLen = val.length;
                if(this.addduty){
                    if(val.length>0 && this.departmentCode<=val[0].code){
                        this.formValidate.departmentName=val[0].fullTitle;
                        this.formValidate.departmentNameCopy = val[0].fullTitle;
                        this.formValidate.departmentCode=val[0].code;
                        this.formValidate.departmentCodeCopy=val[0].code;
                        this.searchData();
                    }else {
                        this.formValidate.departmentCode='';
                        this.formValidate.departmentCodeCopy='';
                        this.formValidate.departmentName='';
                        this.formValidate.departmentNameCopy = '';
                        this.searchData();
                    }
                }else if(val.length>0){
                    if(this.departmentCode<=val[0].code){
                        this.formValidate.departmentName=val[0].fullTitle;
                        this.formValidate.departmentNameCopy = val[0].fullTitle;
                        this.formValidate.departmentCode=val[0].code;
                        this.formValidate.departmentCodeCopy=val[0].code;
                    }else {
                        this.formValidate.departmentCode='';
                        this.formValidate.departmentCodeCopy='';
                        this.formValidate.departmentName='';
                        this.formValidate.departmentNameCopy = '';
                        this.$Message.error('权限不够，无法新增，请联系管理员！');
                    }
                }else {
                    this.formValidate.departmentCode='';
                    this.formValidate.departmentCodeCopy='';
                    this.formValidate.departmentName='';
                    this.formValidate.departmentNameCopy = '';
                }
            },
            //搜索
            searchData(){
                this.pageNo=1;
                this.gasDutyFlipList();
            },
            //日期格式转换
            dateformatting(dateval) {
                var newTime = new Date(dateval);
                var yyyy = newTime.getFullYear();
                var MM = newTime.getMonth() + 1;
                var dd = newTime.getDate();
                var hh = newTime.getHours();
                var mm = newTime.getMinutes();
                var ss = newTime.getSeconds();
                var time = yyyy + "-" + MM + "-" + dd + " " + hh + ":" + mm + ":" + ss;
                return time
            },
            //新增
            addnew() {
                this.formValidate.departmentName =  this.formValidate.departmentNameCopy;
                this.formValidate.departmentCode=this.formValidate.departmentCodeCopy;
                this.addduty = false;
                this.formValidate.id = "";
//                this.compile = true;
            },
            //返回
            returnBtn() {
/*                if( this.formValidate.id !==""){
                    this.compileReset('formValidate');
                    this.organizationFlipList();
                }*/
                this.formValidate.departmentNameCopy = '';
                this.formValidate.departmentCode = '';
                this.compileReset('formValidate');
                this.gasDutyFlipList();
                this.organizationFlipList();
                this.addduty = true;
            },
            //查看值班详情
            examineDuty(val) {
                this.formValidate.id=val.id;
                this.formValidate.departmentCode=val.departmentCode;
                this.formValidate.departmentName=val.departmentName;
                this.formValidate.beginTime=val.beginTime;
                this.formValidate.endTime=val.endTime;
                this.formValidate.combatReadLevel=val.combatReadLevel;
                this.formValidate.captain=val.captain;
                this.formValidate.monitor=val.monitor;
                this.formValidate.telephoneOpeartor=val.telephoneOpeartor;
                this.formValidate.perNum=val.perNum;
                this.formValidate.beAttend=val.beAttend;
                this.formValidate.attend=val.attend;
                this.formValidate.vehicleNum=val.vehicleNum;
                this.formValidate.vehicleStatus=val.vehicleStatus;
                this.formValidate.rescueEquipment=val.rescueEquipment;
                this.formValidate.mobileCharging=val.mobileCharging;
                this.formValidate.fixedInflation=val.fixedInflation;
                this.formValidate.otherVehicle=val.otherVehicle;
                this.formValidate.workMemo=val.workMemo;
                this.formValidate.alarmRecord=val.alarmRecord;
                this.formValidate.notice=val.notice;
                this.formValidate.remarks=val.remarks;
                this.formValidate.combatReadLevel=val.combatReadLevel;
                this.formValidate.leaderSignature=val.leaderSignature;
                this.inspectionDuty = true;
            },
            //修改
            amend(val) {
                this.formValidate.id=val.id;
                this.formValidate.departmentCode=val.departmentCode;
                this.formValidate.departmentName=val.departmentName;
                this.formValidate.beginTime=val.beginTime;
                this.formValidate.endTime=val.endTime;
                this.formValidate.combatReadLevel=val.combatReadLevel;
                this.formValidate.captain=val.captain;
                this.formValidate.monitor=val.monitor;
                this.formValidate.telephoneOpeartor=val.telephoneOpeartor;
                this.formValidate.perNum=val.perNum;
                this.formValidate.beAttend=val.beAttend;
                this.formValidate.attend=val.attend;
                this.formValidate.vehicleNum=val.vehicleNum;
                this.formValidate.vehicleStatus=val.vehicleStatus;
                this.formValidate.rescueEquipment=val.rescueEquipment;
                this.formValidate.mobileCharging=val.mobileCharging;
                this.formValidate.fixedInflation=val.fixedInflation;
                this.formValidate.otherVehicle=val.otherVehicle;
                this.formValidate.workMemo=val.workMemo;
                this.formValidate.alarmRecord=val.alarmRecord;
                this.formValidate.notice=val.notice;
                this.formValidate.remarks=val.remarks;
                this.formValidate.combatReadLevel=val.combatReadLevel;
                this.formValidate.leaderSignature=val.leaderSignature;
                this.addduty = false;
            },
            //新增,修改大队值班提交
            compileSubmit(name) {
                this.$refs[name].validate((valid) => {
                    if (valid) {
                        var _this = this;
                        ezjsUtil.request(apiConstants.gasDuty_edit,
                            {
                                id: _this.formValidate.id,
                                departmentCode: _this.formValidate.departmentCode,
                                departmentName: _this.formValidate.departmentName,
                                beginTime: _this.formValidate.beginTime,
                                endTime: _this.formValidate.endTime,
                                combatReadLevel: _this.formValidate.combatReadLevel,
                                captain: _this.formValidate.captain,
                                monitor: _this.formValidate.monitor,
                                telephoneOpeartor: _this.formValidate.telephoneOpeartor,
                                perNum: _this.formValidate.perNum,
                                beAttend: _this.formValidate.beAttend,
                                attend: _this.formValidate.attend,
                                vehicleNum: _this.formValidate.vehicleNum,
                                vehicleStatus: _this.formValidate.vehicleStatus,
                                rescueEquipment: _this.formValidate.rescueEquipment,
                                mobileCharging: _this.formValidate.mobileCharging,
                                fixedInflation: _this.formValidate.fixedInflation,
                                otherVehicle: _this.formValidate.otherVehicle,
                                workMemo: _this.formValidate.workMemo,
                                alarmRecord: _this.formValidate.alarmRecord,
                                notice: _this.formValidate.notice,
                                remarks: _this.formValidate.remarks,
                                combatReadLevel: _this.formValidate.combatReadLevel,
                                leaderSignature: _this.formValidate.leaderSignature,
                            },
                            function (err, data) {
                                if (err) {
                                    return;
                                }
                                _this.formValidate.departmentName ='';
                                _this.formValidate.departmentCode= '';
                                _this.formValidate.departmentNameCopy = '';
                                _this.formValidate.departmentCodeCopy = '';
                                _this.pageNo = 1;
                                _this.gasDutyFlipList();
                                _this.organizationFlipList();
                            }
                        )
                        _this.$Message.success('提交成功!');
                        _this.addduty = true;
                        _this.compileReset('formValidate');
                    } else {
                        this.$Message.error('表单验证失败!');
                    }
                })
            },
            //表单重置
            compileReset(name) {
                this.$refs[name].resetFields();
            },
            //表格勾选
            compileSelect(selection, row) {
                var ids=[];
                for (var i=0;i<selection.length;i++){
                    ids.push(selection[i].id);
                }
                this.compiledele=ids.join(',');
            },
            //批量删除
            batchDelete() {
                if(this.compiledele) {
                    this.gasDutyRemoveByIds(this.compiledele);
                }else {
                    this.$Message.error('请选择删除项!');
                }
            },
            //表单取消
            compileCancel() {
                this.compile = false;
                this.compileReset('formValidate');
            },

            //值班详情窗口关闭
            recordCancel() {
                this.inspectionDuty = false;
                this.compileReset('formValidate');
                this.formValidate.departmentCode='';
            },
            //分页改变时
            pageChange(val) {
                if (val <= this.totalPage) {
                    this.pageNo = val;
                    this.gasDutyFlipList();
                }
            },
            //查看检验记录表格分页
            recordPageChange(val) {
                if (val <= this.RecordPage.totalPage) {
                    this.RecordPage.pageNo = val;
                    this.groupDutyStatusFlipList();
                }
            },
            //查询气防站值班列表
            gasDutyFlipList() {
                var _this = this;
                ezjsUtil.request(apiConstants.gasDuty_flipList,
                    {
                        beginTime:_this.searchBeginTime,
                        endTime:_this.searchEndTime,
                        departmentCode:_this.formValidate.departmentCode,
                        pageNo: _this.pageNo
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.tabledata = data.listInfo;
                        _this.totalCount = data.flipInfo.totalCount;
                        _this.totalPage = data.flipInfo.totalPage;
                    }
                )
            },
            //批量删除气防站值班记录
            gasDutyRemoveByIds(delid) {
                var _this = this;
                ezjsUtil.request(apiConstants.gasDuty_removeByIds,
                    {
                        ids: delid
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.compiledele='';
                        _this.gasDutyFlipList();
                    }
                )
            },

            //获取所有组织机构树
            organizationFlipList() {
                var _this = this;
                ezjsUtil.request(apiConstants.organization_flipList,
                    { },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.organizationTreeData=data;
                        _this.organizationTreeData[0].expand=true;
                    }
                )
            },
        },
        mounted() {
        }
    }
</script>
<style lang="less" scoped>
    .pack {
        width: 100%;
        height: 100%;
    }

    .tree_container {
        width: 260px;
        height: 100%;
        float: left;
        border: 1px solid #d3d8e0;

    h3 {
        line-height: 40px;
        text-align: center;
        font-size: 14px;
        color: #6e6d6d;
    }
    .treePack{
        height: 94%;
        padding: 10px;
        overflow: auto;
    }
    }
    .detail_container {
        height: 100%;
        margin-left: 280px;
        overflow: hidden;
        overflow-y: auto;
    }

    h3 {
        height: 40px;
        line-height: 40px;
        border-bottom: 1px solid #d3d8e0;
    }

    .hunttool, .hunttoolreturn {
        height: 54px;
        padding: 15px 0;

    .addbtn {
        margin-right: 6px;
        float: right;
    }

    .deltebtn {
        margin-right: 6px;
        float: right;
    }

    }
    .hunt {
        width: 14rem;
    }

    .page_container {
        height: 30px;
        margin-top: 20px;

    .page_btn {
        float: right;
    }

    .page_text {
        float: right;
        line-height: 26px;
    }

    }

    .right-card {
        margin-bottom: 20px;
    }
</style>